package com.bestcem.xm.user.enums;

import com.alibaba.excel.util.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 限额通知用户相关枚举
 *
 * @author qiongyu.cui <qiongyu.cui@idiaoyan.com>
 * @version v1.0
 * @date 2022/7/14 16:51
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum NotifyQuotaReachedEnum {

    /**
     * 限额通知用户相关枚举
     */
    QUOTA(1, "已达限额", "限额", "【倍市得CEM】项目数到限额"),
    CONSUMPTION(2, "已使用", "用量", "【倍市得CEM】项目数即将到达限额");

    private Integer type;
    private String rateStr;
    private String notifyTitle;
    private String mailSubject;

    /**
     * 根据配额使用率返回限额通知类型枚举
     *
     * @param quotaRate 限额使用率 0.5 1
     * @author cuiqiongyu <qiongyu.cui@idiaoyan.cn>
     * @date 2022/07/14 16:57
     */
    public static NotifyQuotaReachedEnum getByQuotaRate(String quotaRate) {
        if (StringUtils.isNotBlank(quotaRate) && "1".equals(quotaRate)) {
            return QUOTA;
        }
        return CONSUMPTION;
    }

}
